package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.vo.WxSearchVo;
import com.cskaoyan.service.WxSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedList;
import java.util.List;

/**
 * @author yi
 * @date 2022/10/14 21:51
 */

@RestController
@RequestMapping("wx/search")
public class WxSearchController {
    @Autowired
    WxSearchService wxSearchService;

    @RequestMapping("index")
    public BaseRespVo index() {
        WxSearchVo wxSearchVo = wxSearchService.queryIndex();
        return BaseRespVo.ok(wxSearchVo, "成功");
    }

    @RequestMapping("helper")
    public BaseRespVo helper(String keyword) {
        List<String> goodsNameList = wxSearchService.queryGoodsName(keyword);
        return BaseRespVo.ok(goodsNameList, "成功");
    }

    @RequestMapping("clearhistory")
    public BaseRespVo clearhistory() {
        wxSearchService.clearHistory();
        return BaseRespVo.ok("成功");
    }
}
